#!/usr/bin/env bash

# Some constant colors
DEFAULT="\e[39m"
GREEN="\e[32m"
CYAN="\e[96m"
RED="\e[91m"
YELLOW="\e[93m"

# title function
title () {
	clear
	echo -e "${CYAN}###########################################"
	echo -e " Setting up a Github repository"
	echo -e "###########################################${DEFAULT}"
	echo
}

prompt() {
	echo -e -n "${YELLOW}$1 ${DEFAULT}"
	read $2
}

showdone() {
	echo -e "${CYAN}###########################################"
	echo -e " All done, have fun :)"
	echo -e "###########################################${DEFAULT}"
	echo	
}
# echo "# Simple git-tools" >> README.md
# git init
# git add README.md
# git commit -m "first commit"
# git remote add origin https://github.com/ArchWiz/git-tools.git
# git push -u origin master

# git config --global user.name x
# git config --global user.email x
# sudo git config --system core.editor nano
# git config --global credential.helper cache
# git config --global credential.helper 'cache --timeout=3600'

# Force git to overwrite local files on pull - no merge
# git fetch all
# git push --set-upstream origin master
# git reset --hard orgin/master

if ! location="$(type -p 'git')" || [ -z "git" ]; then
	echo 
"${RED}#########################################################"
	echo "Installing git for this script to work"
	echo 
"#########################################################${DEFAULT}"
	sudo apt install git -y
fi

# Setting up git
# 
https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-config

title
prompt "Pleace specify your full name:" fullname
prompt "Pleace specify your e-mail adres:" email
#prompt "Please specify Github username:" username
prompt "Please specify Repository name:" repository

username="Archwiz_Linux"

git init
git config --global user.name "${fullname}"
git config --global user.email "${email}"
sudo git config --system core.editor nano
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=3600'
git config --global push.default simple

git remote add origin https://notabug.org/${username}/${repository}.git

showdone
